#include <stdio.h>

int go_shopping(int cash, int* cap, int* bot)
{
    static int beers = 0;
    int new_beers = cash/2 + *cap/4 + *bot/2;
    beers += new_beers;
    *cap = *cap%4 + new_beers;
    *bot = *bot%2 + new_beers;
    if (*cap<4 && *bot<2)
        return beers;
    return go_shopping(0, cap, bot);
}

int main(int argc, char* argv)
{
    int cash;
    printf("How much you wanna pay:");
    scanf("%d", &cash);
    int change = cash%2;
    int cap = 0;
    int bot = 0;
    printf("You will get %d bottles of beers, and %d caps,%d bottles and %d Yuan will be remained\n", go_shopping(cash, &cap, &bot), cap, bot, change);
    return 0;
}
    
